package com.jiaomatech.demo.user.controller;

import com.jiaomatech.demo.user.aspect.log.TimeLog;
import com.jiaomatech.demo.user.dto.UserDto;
import com.jiaomatech.demo.user.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * Description: 用户查询 .<br>
 *
 * @author m-xy
 *     Created By 2019/10/18 14:10
 */
@RestController
@RequestMapping("/user")
@Api(tags = "用户信息查询服务")
public class UserSearchController {
    private final static Logger logger = LoggerFactory.getLogger(UserSearchController.class);
    @Autowired private UserService userService;

    /**
     * 查询用户信息 .
     *
     * @param userId
     * @return ResponseEntity.
     */
    @RequestMapping(value = "/{userId}", method = RequestMethod.GET,
                    produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiImplicitParams( {
                            @ApiImplicitParam(paramType = "path", name = "userId", dataType = "String",
                                              required = true, value = "用户ID")
                        })
    @ApiOperation(value = "查询用户信息",
                  notes = "孟祥元开发于 2019/10/18 14:10 。")
    @TimeLog("查询用户信息")
    public ResponseEntity<UserDto> findUserById(@PathVariable("userId") String userId) {
        return ResponseEntity.ok(userService.findUserById(userId));
    }
}
